package view;

import java.awt.Color;
import java.awt.Rectangle;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;

/**
 * The Class ProduceReportGUI that extends AbstractGUI.
 * @author yudku
 */
public class ProduceReportGUI extends AbstractGUI
{
	
	/** The get complaint stat. */
	private JButton getComplaintStat = null;
	
	/** The get archive stat. */
	private JButton getArchiveStat = null;
	
	/** The get package usage. */
	private JButton getPackageUsage = null;
	
	/** The content pane. */
	private JPanel contentPane=null;
	
	/** The wrn message. */
	private JLabel wrnMessage=null;
	
	/**
	 * Instantiates a new produce report gui.
	 */
	public ProduceReportGUI()
	{
		super ();
		contentPane=new JPanel();
	    contentPane.setBorder(new TitledBorder(null, "Produce Report", TitledBorder.LEADING, TitledBorder.TOP, null, null));	    
	    contentPane.setLayout(null);
	    contentPane.setOpaque(true);
	    contentPane.add(getComplaintStat());
	    contentPane.add(getArchiveStat());   	
	    contentPane.add(getPackageUsage());
	    contentPane.add(getBackButton());	
	    contentPane.add(getWrnMessage());

		  //Frame
	        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	        this.setTitle("Produce report window");
	        this.setContentPane(contentPane);  
		    this.setLocationRelativeTo(null); //This will center the JFrame in the middle of the screen
	        this.setLocationByPlatform(true);
	        this.setSize(593, 265);
	        this.setVisible( true ); // display frame
	
	}
	
	
	/**
	 * This method initializes Complaint Stats Photo Button.
	 *
	 * @return the complaint stat
	 */
	private JButton getComplaintStat() {
		if (getComplaintStat == null) {
			getComplaintStat = new JButton();
			getComplaintStat.setBounds(new Rectangle(10, 76, 161, 45));
			getComplaintStat.setText("Complaint Stats");
			getComplaintStat.addActionListener(new java.awt.event.ActionListener() 
			{
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
									
				}
			});
		}
		return getComplaintStat;
	}
	
	/**
	 * This method initializes Archive Stats Button.
	 *
	 * @return the archive stat
	 */
	private JButton getArchiveStat() {
		if (getArchiveStat == null) {
			getArchiveStat = new JButton();
			getArchiveStat.setBounds(new Rectangle(204, 76, 161, 45));
			getArchiveStat.setText("Archive Stats");
			getArchiveStat.addActionListener(new java.awt.event.ActionListener() 
			{
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					
				}
			});
		}
		return getArchiveStat;
	}
	
	/**
	 * Gets the wrn message.
	 *
	 * @return the wrn message
	 */
	private JLabel getWrnMessage() {
		if (wrnMessage == null) {
			wrnMessage = new JLabel();
			wrnMessage.setForeground(Color.RED);
			wrnMessage.setBounds(113, 41, 320, 23);
			wrnMessage.setVisible(false);
		}
		return wrnMessage;
	}
	
	/**
	 * This method initializes Package Usages Button.
	 *
	 * @return the package usage
	 */	
	private JButton getPackageUsage() {
		if (getPackageUsage == null) {
			getPackageUsage = new JButton();
			getPackageUsage.setBounds(new Rectangle(395, 76, 161, 45));
			getPackageUsage.setText("Package Usages");
			getPackageUsage.addActionListener(new java.awt.event.ActionListener() 
			{
				public void actionPerformed(java.awt.event.ActionEvent e) 
				{
					
				}
			});
		}
		return getPackageUsage;
	}
	
	/**
	 * This method initializes Back Button.
	 *
	 * @return the back button
	 */
	private JButton getBackButton() {
		if (backButton == null) {
			backButton = new JButton();
			backButton.setBounds(new Rectangle(204, 150, 161, 45));
			backButton.setText("Back to main");
			
		}
		return backButton;
	}
	
	/**
	 * Display wrn message.
	 *
	 * @param msg the msg
	 */
	public void displayWrnMessage(String msg){
		wrnMessage.setText(msg);
		wrnMessage.setVisible(true);
	}
	
	/**
	 * Adds the complaint button listener.
	 *
	 * @param listener the listener
	 */
	public void addComplaintButtonListener(ActionListener listener)
	{
		getComplaintStat.addActionListener(listener);
	}
	
	/**
	 * Adds the archive button listener.
	 *
	 * @param listener the listener
	 */
	public void addArchiveButtonListener(ActionListener listener)
	{
		getArchiveStat.addActionListener(listener);
	}
	
	/**
	 * Adds the package button listener.
	 *
	 * @param listener the listener
	 */
	public void addPackageButtonListener(ActionListener listener)
	{
		getPackageUsage.addActionListener(listener);
	}
}
